﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Happy.ExtentionMethods;

namespace Happy.Examples.OrderManagement.Domain.Orders
{
    public sealed class OrderFactory
    {
        private readonly IOrderCodeGenerator _orderCodeService;

        public OrderFactory(IOrderCodeGenerator orderCodeService)
        {
            orderCodeService.MustNotNull("orderCodeService");

            _orderCodeService = orderCodeService;
        }

        public Order Create(CustomerInfo customerInfo)
        {
            customerInfo.MustNotNull("customerInfo");

            var orderCode = _orderCodeService.NextOrderCode();

            return new Order(orderCode, customerInfo);
        }
    }
}
